//
//  LSBaseSettingViewController.m
//  LookScore
//
//  Created by wr on 2017/12/9.
//  Copyright © 2017年 ChongQingXunTiCompany. All rights reserved.
//

#import "LSBaseSettingViewController.h"
#import "LSNavigationViewController.h"
#import "LSHomeVController.h"
//#import "UIViewController+CWLateralSlide.h"
#import "LSCompetitionVController.h"
#import "LSExponentVController.h"
#import "LSChatCircleVController.h"

#import "LSMineVController.h"//我的
#import "LSLossPerCentCompanyVController.h"//赔率公司 指数
#import "LSRevealSettingVController.h"//显示设置 赛事
#import "LSFiltrateCompetitionVController.h"//塞选赛事
#import "LSDataBankVController.h"//资料库
//#import "UIViewController+CWLateralSlide.h"
#import "LSExponentModel.h"
#import "LSDataLeagueModel.h"
#import "XYSideViewController.h"
#import "UIViewController+XYSideCategory.h"


@interface LSBaseSettingViewController ()<UINavigationControllerDelegate>


@property(strong,nonatomic)UIButton *leftButton;

@property(strong,nonatomic)UIButton *rightLeftButton;

@property(strong,nonatomic)UIButton *rightRightButton;
@property (nonatomic, strong) NSMutableArray * leagueNameArray;
@end

@implementation LSBaseSettingViewController

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    /**左*/
    UIButton *LeftButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 37, 37)];
    LeftButton.layer.cornerRadius = LeftButton.bounds.size.width/2.0f;
    LeftButton.layer.masksToBounds = true;
    LeftButton.tag=10;
    [LeftButton addTarget:self action:@selector(navgationEvent:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:LeftButton];
    self.leftButton=LeftButton;
    LeftButton.hidden=YES;
    
    /**右左*/
    UIButton *rightLeftButton = [[UIButton alloc]initWithFrame:CGRectMake(0,0,22,22)];
    [rightLeftButton addTarget:self action:@selector(navgationEvent:) forControlEvents:UIControlEventTouchUpInside];
    rightLeftButton.tag=11;
    UIBarButtonItem *NavSettingBui = [[UIBarButtonItem alloc]initWithCustomView:rightLeftButton];
    self.rightLeftButton=rightLeftButton;
    rightLeftButton.hidden=YES;
    
    /**右右*/
    UIButton *rightRightButton = [[UIButton alloc]initWithFrame:CGRectMake(0,0,22,22)];
    [rightRightButton addTarget:self action:@selector(navgationEvent:) forControlEvents:UIControlEventTouchUpInside];
    rightRightButton.tag=12;
//    UIBarButtonItem *DataBankBuI = [[UIBarButtonItem alloc]initWithCustomView:rightRightButton];
//    self.navigationItem.rightBarButtonItems=@[NavSettingBui ,DataBankBuI];
    self.navigationItem.rightBarButtonItems=@[NavSettingBui];
    self.rightRightButton=rightRightButton;
    rightRightButton.hidden=YES;
}

-(void)setImageArray:(NSArray *)imageArray{
    _imageArray=imageArray;
    
    if([self isKindOfClass:[LSHomeVController class]]){
        
        self.leftButton.hidden=NO;
        [self.leftButton setImage:[UIImage imageNamed:_imageArray[0]] forState:UIControlStateNormal];
        
    }else if ([self isKindOfClass:[LSCompetitionVController class]]){
        
        self.leftButton.hidden=NO;
        [self.leftButton setImage:[UIImage imageNamed:_imageArray[0]] forState:UIControlStateNormal];
        self.rightLeftButton.hidden=NO;
        [self.rightLeftButton setImage:[UIImage imageNamed:_imageArray[1]] forState:UIControlStateNormal];
        self.rightRightButton.hidden=NO;
        [self.rightRightButton setImage:[UIImage imageNamed:_imageArray[2]] forState:UIControlStateNormal];
        
    }
//    else if ([self isKindOfClass:[LSExponentVController class]]){
//
//        self.leftButton.hidden=NO;
//        [self.leftButton setImage:[UIImage imageNamed:_imageArray[0]] forState:UIControlStateNormal];
//        self.rightLeftButton.hidden=NO;
//        [self.rightLeftButton setImage:[UIImage imageNamed:_imageArray[1]] forState:UIControlStateNormal];
//        self.rightRightButton.hidden=NO;
//        [self.rightRightButton setImage:[UIImage imageNamed:_imageArray[2]] forState:UIControlStateNormal];
//
//    }
   
    
}

-(void)navgationEvent:(UIBarButtonItem *)barButton{
   
    if([self isKindOfClass:[LSHomeVController class]]){

//        LSMineVController *loginVC=[[LSMineVController alloc]init];
//        LSNavigationViewController *nva= [[LSNavigationViewController alloc] initWithRootViewController:loginVC];
//        nva.modalPresentationStyle=UIModalPresentationOverFullScreen;
//        [self presentViewController:nva animated:NO completion:nil];

//        LSMineVController *loginVC=[[LSMineVController alloc]init];
//        LSNavigationViewController *nva= [[LSNavigationViewController alloc] initWithRootViewController:loginVC];
//        nva.modalPresentationStyle=UIModalPresentationOverFullScreen;
//        [self presentViewController:nva animated:NO completion:nil];
        


//        LSMineVController *loginVC=[[LSMineVController alloc]init];
        [self XYSideOpenVC];

//        LSMineVController *loginVC=[[LSMineVController alloc]init];
//        [self cw_showDefaultDrawerViewController:loginVC];

//        [self cw_showDefaultDrawerViewController:loginVC];

        

    }else if ([self isKindOfClass:[LSCompetitionVController class]]){
        
        //赛事
        switch (barButton.tag) {
                case 10:{
                    LSFiltrateCompetitionVController *filtrateVC=[[LSFiltrateCompetitionVController alloc]init];
                    filtrateVC.filtrateType=LSFiltrateCompetitionIsCompetitionType;
                    filtrateVC.competitionBlock = ^(NSMutableArray *leaArray, NSMutableArray *zouLeaNameArray,NSInteger type) {
//                        [self changCompetitionLeagueNameArray:leaArray withType:type];
                        [self changCompetitionLeagueNameArray:leaArray withZouNameArray:zouLeaNameArray withType:type];
                    };
                    
                    MyLog(@"%ld",self.superComtitionArray.count);
                    filtrateVC.compitionArray = self.leaArray.mutableCopy;
                    filtrateVC.leaArray = self.leaArray.mutableCopy;
                    filtrateVC.zouArray = self.zouLeaArray.mutableCopy;
                    [self.navigationController pushViewController:filtrateVC animated:YES];
                }
                break;
                case 11:{
                    LSRevealSettingVController *settingVC = [[LSRevealSettingVController alloc] init];
                    [self.navigationController pushViewController:settingVC animated:YES];
                   
                }
                break;
                case 12:{
                    LSDataBankVController *dataVC=[[LSDataBankVController alloc]init];
                    dataVC.title = @"资料库";
                    [self.navigationController pushViewController:dataVC animated:YES];
//                    [MBProgressHUD showOnlyMessage:@"正在建设中。。。" afterDelay:1.5f];
                }
                break;
                
            default:
                break;
        }

    }
    else if ([self isKindOfClass:[LSExponentVController class]]){
        //指数
        switch (barButton.tag) {
            case 10:{
                LSFiltrateCompetitionVController *filtrateVC=[[LSFiltrateCompetitionVController alloc]init];
                filtrateVC.filtrateType=LSFiltrateCompetitionIsExponentType;
                
                
                
                filtrateVC.block = ^(NSMutableArray *nameArray) {
                    [self changLeagueNameArray:nameArray];
                    self.leagueNameArray = nameArray.mutableCopy;
                };
                 NSMutableArray * compitionArray = [self judgeScreeningButtonIsSelectedWithModelArray:self.leagueArray.mutableCopy WithNameArray:self.leagueNameArray];
                filtrateVC.leagueArray = compitionArray;
                [self.navigationController pushViewController:filtrateVC animated:YES];
                
            }
                break;
            case 11:{
                
                LSLossPerCentCompanyVController *companyVC=[[LSLossPerCentCompanyVController alloc]init];
                companyVC.companyArr = self.companyArr;
                
                companyVC.block = ^(NSMutableArray *selectCompanyArr) {
                    [self changeValue:selectCompanyArr];
                };
                [self.navigationController pushViewController:companyVC animated:YES];
               
            }
                break;
            case 12:{
                [MBProgressHUD showOnlyMessage:@"正在建设中。。。" afterDelay:1.5f];
//                LSDataBankVController *dataVC=[[LSDataBankVController alloc]init];
//                [self.navigationController pushViewController:dataVC animated:YES];
            }
                break;
                
            default:
                break;
        }
        
    }
}

- (NSMutableArray *)companyArr{
    if (!_companyArr) {
        _companyArr = @[].mutableCopy;
    }
    return _companyArr;
}
- (NSMutableArray *)judgeScreeningButtonIsSelectedWithModelArray:(NSMutableArray *)modelArray WithNameArray:(NSMutableArray *)nameArray{
    
    NSMutableArray * array = modelArray.mutableCopy;
    for (LSDataLeagueModel * model in array) {
        if (self.leagueNameArray.count != 0) {
            BOOL isHas = YES;
            for (NSString * name  in nameArray) {
                if ([name isEqualToString:model.LeagueName_CN]) {
                    isHas = NO;
                }
            }
            if (isHas) {
                model.isBtnSelected = NO;
            }else{
                model.isBtnSelected = YES;
            }
            
        }else{
            model.isBtnSelected = YES;
        }
        
        
    }
    return array;
}

- (void)changeValue:(NSMutableArray *)companyArr{
    
    
    
}

- (void)changLeagueNameArray:(NSMutableArray *)leagueNameArray{
    
    
}

- (void)changCompetitionLeagueNameArray:(NSMutableArray *)leagueNameArray withZouNameArray:(NSMutableArray *)zouNameArray withType:(NSInteger)type{
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
